package com.yitiao.data_algorithms.leetcode.editor.cn;

class HouseRobber {
    // 2024-06-15 16:24:44
    public static void main(String[] args) {
        Solution solution = new HouseRobber().new Solution();
    }

    //leetcode submit region begin(Prohibit modification and deletion)
    class Solution {
        public int rob(int[] nums) {
            int[] dp = new int[nums.length + 1];
            dp[0] = 0;
            dp[1] = nums[0];
            for (int i = 2; i < dp.length; i++) {
                dp[i] = Math.max(dp[i - 1], dp[i - 2] + nums[i - 1]);
            }
            return dp[nums.length];
        }
    }
//leetcode submit region end(Prohibit modification and deletion)

}